<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript" src="../js/jquery-1.11.0.min.js"></script>
<script type="text/javascript">

function update(id){
	
	$.ajax({
		type:'post',
		url:'${pageContext.request.contextPath}/elecStatus/selectById.action',
		data:'id='+id,
		success:function(data){
			window.location.href="${pageContext.request.contextPath}/elecStatus/returnView.action";
		}
	})
	/* $('#show').html("<tr><td>Show</td><td>This</td></tr><tr><td>Show</td><td>This</td></tr>"); */
}

function showList(){
	window.location.href="${pageContext.request.contextPath}/elecStatus/getList.action";
}
</script>
</head>
<body>
	<h1>设备数据模拟传送---对应电表状态页</h1>
	<p><a href="${pageContext.request.contextPath}/jsp/getJsonData.jsp">数据码头</a>http://localhost:8080/EMS/jsp/getJsonData.jsp</p>
     
      <button onclick="showList()">返回</button>
		<table cellspacing="0" cellpadding="0" border="1" width="800px"
				style="text-align: center; border: solid 1px white;">
				<tr>
					<td>设备ID</td>
					<td>设备名称:</td>
					<td>开关:</td>
					<td>数据值：</td>
					<td>操作</td>
				</tr>
		<c:forEach items="${elecList}" var="elec">			
				<tr>
					<td><input type="text" name="id" value="${elec.id}"></td>
					<td><input type="text" name="name" value="${elec.name}"></td>
					<td><input type="text" name="status" value="${elec.status}"></td>
					<td><input type="text" name="data" value="${elec.data}"></td>
				    <td><button onclick="update(${elec.id})">修改</button></td>
				</tr>		
		</c:forEach>
		</table>
		<br>
		<hr>
		<br>
		<form action="${pageContext.request.contextPath}/elecStatus/selectByName.action" method="post">
			<table cellspacing="0" cellpadding="0" border="1" width="800px"
				style="text-align: center; border: solid 1px white;">
				<tr>
					<td>设备ID</td>
					<td>设备名称:</td>
					<td>开关:</td>
					<td>数据值：</td>
					<td>操作</td>
				</tr>
				
				<tr>
					<td><input type="text" name="id" value="${elecStatus1.id}"></td>
					<td><input type="text" name="name" value="${elecStatus1.name}"></td>
					<td><input type="text" name="status" value="${elecStatus1.status}"></td>
					<td><input type="text" name="data" value="${elecStatus1.data}"></td>
				    <td><button type="submit">修改</button></td>
				</tr>		
		
		</table>
	</form>
	
	
	
</body>
</html>